package 数字图像处理.imagetests;

import org.junit.Test;
import 数字图像处理.filter.WaveFilter;
import 数字图像处理.imageutils.ImageUtils;

/**
 * @author Summerday
 */
public class WaveFilterTest {
    int[][] MeanMatrix = {
            {1, 1, 1},
            {1, 1, 1},
            {1, 1, 1}
    };
    int[][] arr = {
            {59, 60, 58, 57},
            {61, 90, 59, 57},
            {62, 59, 0, 58},
            {59, 61, 60, 56},
    };
    int[][] test = {
            {1, 2, 1, 4, 3},
            {1, 2, 2, 3, 4},
            {5, 7, 6, 8, 9},
            {5, 7, 6, 8, 8},
            {5, 6, 7, 8, 9}
    };

    int[][] knnTest = {
            {1, 2, 1, 4, 3},
            {1, 2, 2, 3, 4},
            {5, 7, 6, 8, 9},
            {5, 7, 6, 8, 8},
            {5, 6, 7, 8, 9},
    };

    int[][] knn = {
            {1, 5, 255, 100, 200, 200},
            {1, 7, 254, 101,  10,   9},
            {3, 7,  10, 100,   2,   6},
            {1, 0,   8,   7,   2,   1},
            {1, 1,   6,  50,   2,   2},
            {2, 3,   9,   7,   2,   0},
    };

    @Test
    public void testMean() {

        WaveFilter waveFilter = new WaveFilter(arr);
        System.out.println("=====模块运算系数=====");
        waveFilter.list(MeanMatrix);
        System.out.println("======= 原图 =======");
        waveFilter.list(arr);
        ImageUtils.computeContrast(arr);
        System.out.println("===== 均值滤波  =====");
        int[][] results = waveFilter.meanFilter();
        waveFilter.list(results);
        ImageUtils.computeContrast(results);

    }

    @Test
    public void testMedian() {


        System.out.println("======= 原图 =======");
        WaveFilter waveFilter = new WaveFilter(arr);
        waveFilter.list(arr);
        ImageUtils.computeContrast(arr);
        System.out.println("===== 中值滤波  =====");
        int[][] results = waveFilter.medianFilter();
        waveFilter.list(results);
        ImageUtils.computeContrast(results);
    }

    @Test
    public void testKNN() {
        System.out.println("======= 原图 =======");
        WaveFilter waveFilter = new WaveFilter(knn);
        waveFilter.list(knn);
        ImageUtils.computeContrast(knn);
        System.out.println("======= knn =======");
        int[][] ints = waveFilter.knnFilter(5);
        waveFilter.list(ints);
        ImageUtils.computeContrast(ints);


    }
    @Test
    public void testSym(){
        System.out.println("======= 原图 =======");
        WaveFilter waveFilter = new WaveFilter(knn);
        waveFilter.list(knn);
        ImageUtils.computeContrast(knn);
        System.out.println("====== 对称近邻 ======");
        int[][] ints = waveFilter.symmetricFilter();
        waveFilter.list(ints);
        ImageUtils.computeContrast(ints);
    }
    @Test
    public void testSigma(){
        System.out.println("======= 原图 =======");
        WaveFilter waveFilter = new WaveFilter(knn);
        waveFilter.list(knn);
        ImageUtils.computeContrast(knn);
        System.out.println("====== Sigma ====== ");
        int[][] ints = waveFilter.sigmaFilter();
        waveFilter.list(ints);
        ImageUtils.computeContrast(ints);
    }



}
